#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int mod=998244353,inv2=499122177;
const int N=3e5+9;

struct Matrix{
	int a[7][7];
};
Matrix operator* (Matrix x,Matrix y)
{
	Matrix ans;
	for(int i=0;i<=6;i++)
	for(int j=0;j<=6;j++)
	{
		ans.a[i][j]=0;
		for(int k=0;k<=6;k++)
		ans.a[i][j]=(ans.a[i][j]+1ll*x.a[i][k]*y.a[k][j])%mod;
	}
	return ans;
}
Matrix I,zy;
Matrix ksm(Matrix x,int y){Matrix z=I;for(;y;x=x*x,y>>=1) if(y&1) z=z*x;return z;}
int ksm(int x,int y){int z=1;for(;y;x=1ll*x*x%mod,y>>=1) if(y&1) z=1ll*z*x%mod;return z;}

int n,K,Q;
int p[N];
int opt[N][2];
int res[N];

int BIT[N];
void Add(int i,int x){for(;i<=n;i+=(i&(-i))) (BIT[i]+=x)%=mod;}
int Ask(int i){int x=0;for(;i;i-=(i&(-i))) (x+=BIT[i])%=mod;return x;}
void Clear(){for(int i=1;i<=n;i++) BIT[i]=0;}

signed main()
{
	freopen("random.in","r",stdin);
	freopen("random.out","w",stdout);
	scanf("%d%d%d",&n,&K,&Q);
	for(int i=1;i<=n;i++) scanf("%d",&p[i]);
	for(int i=1;i<=Q;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		opt[i][0]=u;
		opt[i][1]=v;
		swap(p[u],p[v]);
	}
	int c1=1ll*(n-2)*(n-3)/2%mod;
	int c2=(1ll*c1+(n-3))%mod;
	int c3=(1ll*c1+n+n-7+mod)%mod;
	zy=(Matrix){
	{
		{c1,1,	n-2,0,	n-2,0,	0	},
		{1,	c1,	0,	n-2,0,	n-2,0	},
		{1,	0,	c2,	1,	0,	1,	n-3	},
		{0,	1,	1,	c2,	1,	0,	n-3	},
		{1,	0,	0,	1,	c2,	1,	n-3	},
		{0,	1,	1,	0,	1,	c2,	n-3	},
		{0,	0,	1,	1,	1,	1,	c3	},
	}};
	int fm=ksm(1ll*n*(n-1)/2%mod,mod-2);
//	cerr<<fm<<endl;
	
	for(int i=0;i<=6;i++) I.a[i][i]=1;
	for(int i=0;i<=6;i++)
	for(int j=0;j<=6;j++)
	zy.a[i][j]=1ll*zy.a[i][j]*fm%mod;
	
	Matrix zy1=ksm(zy,K-Q);
	int inv=ksm(n-2,mod-2);
	for(int t=Q;t>=0;t--)
	{
		int XY=zy1.a[0][0],
			YX=zy1.a[0][1],
			AY=1ll*zy1.a[0][2]*inv%mod,
			YA=1ll*zy1.a[0][3]*inv%mod,
			XA=1ll*zy1.a[0][4]*inv%mod,
			AX=1ll*zy1.a[0][5]*inv%mod,
			AA=zy1.a[0][6];
//		cerr<<XY<<" "<<YX<<" "<<AY<<" "<<YA<<" "<<XA<<" "<<AX<<" "<<AA<<endl;
		//Case 1: X<Y
		int Sx=0,Sy=0,C=0,ans=0;
		Clear();
		for(int i=1;i<=n;i++) Sx=(Sx+Ask(p[i]))%mod,Add(p[i],p[i]);
		Clear();
		for(int i=1;i<=n;i++) Sy=(Sy+1ll*p[i]*Ask(p[i]))%mod,C=(C+Ask(p[i]))%mod,Add(p[i],1);
//		cerr<<Sx<<" "<<Sy<<" "<<C<<endl;
		
		ans=(ans+1ll*C*YX)%mod;
		ans=(ans+1ll*C*inv2%mod*AA)%mod;
		ans=(ans+1ll*(1ll*n*C%mod-Sy+mod)%mod*AY)%mod;
		ans=(ans+1ll*(Sy-1ll*2*C%mod+mod)%mod*YA)%mod;
		ans=(ans+1ll*(1ll*(n-1)*C%mod-Sx+mod)%mod*AX)%mod;
		ans=(ans+1ll*(Sx-1ll*C%mod+mod)%mod*XA)%mod;
		
		//Case 2: X>Y
		int Sx0=0,Sy0=0,C0=1ll*n*(n-1)/2%mod;
		for(int i=1;i<=n;i++) Sx0=(Sx0+1ll*p[i]*(n-i))%mod;
		for(int i=1;i<=n;i++) Sy0=(Sy0+1ll*p[i]*(i-1))%mod;
		Sx=(Sx0-Sx+mod)%mod;
		Sy=(Sy0-Sy+mod)%mod;
		C=(C0-C+mod)%mod;
//		cerr<<Sx<<" "<<Sy<<" "<<C<<" "<<C0<<endl;
		
		ans=(ans+1ll*C*XY)%mod;
		ans=(ans+1ll*C*inv2%mod*AA)%mod;
		ans=(ans+1ll*(1ll*n*C%mod-Sx+mod)%mod*AX)%mod;
		ans=(ans+1ll*(Sx-1ll*2*C%mod+mod)%mod*XA)%mod;
		ans=(ans+1ll*(1ll*(n-1)*C%mod-Sy+mod)%mod*AY)%mod;
		ans=(ans+1ll*(Sy-1ll*C%mod+mod)%mod*YA)%mod;
		
		res[t]=ans;
		zy1=zy1*zy;
		swap(p[opt[t][0]],p[opt[t][1]]);
	}
	for(int i=0;i<=Q;i++) printf("%d\n",res[i]);
}
